import React, { useEffect, useRef } from "react";

interface MyInputProps {
  value: string;
  onChange: (value: string) => void;
  shouldFocus: boolean;
}
const MyInput: React.FC<MyInputProps> = ({ value, onChange, shouldFocus }) => {
  const ref = useRef<HTMLInputElement>(null);

  useEffect(() => {
    console.log(111);
    if (shouldFocus) {
      ref.current?.focus();
    }
  }, [shouldFocus]);

  return <input ref={ref} value={value} onChange={e => onChange(e.target.value)} />;
};
export default MyInput;
